package com.hundsun.s3.client.web.action;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

/**
 * @description:
 * @author:肖文轩
 * @date:2018/3/13
 **/
@Controller
public class loginAction {

    @Autowired
    HttpSession session;
    @RequestMapping(value="/login.htm")
    public String login(ModelMap model) {
        String username = (String) session.getAttribute("username");
        String nickname = (String)session.getAttribute("nickname");
        model.put("key1", "hs");
        model.put("key2", "club");
        model.put("key3", "33#44");
        return "login";
    }

    @RequestMapping("/index.htm")
    public String index(String id,String nickname) {
        String username = (String)session.getAttribute("username");
        String name = (String)session.getAttribute("nickname");
        if(!(username.equals(id) && name.equals(nickname))) {
            return "redirect:/login.htm";
        }
        return "index";
    }
}
